home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / chekbook.zip / 081592C.CPP next >
C/C++ Source or Header  |  1992-08-26  |  3KB  |  68 lines

  1. #include<stdlib.h>
  2. #include<ctype.h>
  3. #include<stdio.h>                                         /*  header files  */
  4.  
  5. main ()
  6. {
  7. int checks = 0, var = 0;               /*  definitions and initializations  */
  8. float  deposit, s_charge, balance, check;
  9. char  transac, C, D, S;
  10.  
  11.  s_charge = 0;
  12.  
  13.  printf ("C H E C K B O O K     P R O G R A M    F O R    U N I X   &   C\n");
  14.  printf ("\n\nWhat is your opening balance? --> ");/*  ask user for balance  */
  15.  scanf ("%f", &balance);
  16.  printf ("\nYour opening balance is $%7.2f\n", balance);
  17.  printf ("\t\t          Here are the choices:                 \n\n");
  18.  printf ("C:  Checks\n");                                 /*  menu choices  */
  19.  printf ("D:  Deposits\n");
  20.  printf ("S:  Stop Transactions\n");
  21.  loop: printf ("Your choice is-> ");                   /*  first goto loop  */
  22.  fflush(stdin);
  23.  transac = toupper (fgetc(stdin));  /*  get a character from user and make  */
  24.                               /*  it uppercase  */
  25. switch (transac)                                      /*  switch statement  */
  26.  {
  27.  
  28. case 'C': printf ("What is the check money amount? \n");
  29.     scanf ("%f", &check);                         /*  ask for check amount  */
  30.     checks += 1;                                 /*  total the # of checks  */
  31.     balance = balance - check;                      /*  make a new balance  */
  32.     if (balance < 500 ) {                          /*  flag service charge  */
  33.      var = 1;
  34.      }
  35.      goto loop;                               /*  goto: return to menu  */
  36. loop2: if (var == 1)              /*  second goto loop to end transactions  */
  37.     {                                 /*  and report the balance minus the  */
  38.      balance -= .25 * checks;                           /*  service charge  */
  39.      s_charge = .25 * checks;               /*  compute the service charge  */
  40.      printf ("Balance is $%7.2f & it has $%3.2f service charge that was taken off.\n", balance, s_charge);
  41.      break;                                                      /*  break  */
  42.     }
  43.     printf ("Balance is $%7.2f & there was no service charges.", balance);
  44.     break;
  45.  
  46. case 'D': printf ("What is the deposit money amount? \n");
  47.     scanf ("%f", &deposit);                     /*  ask for deposit amount  */
  48.     balance = balance + deposit;                    /*  make a new balance  */
  49.     goto loop;                                                    /*  goto  */
  50.  
  51. case 'S': goto loop2;                       /*  ends transactions and goes  */
  52.                          /*  to compute the totals  */
  53.  
  54. default: printf ("Option is illegal. Start again:\n");/*  account for error */
  55.     goto loop;                                               /*  goto menu  */
  56.     }                                                           /*  switch  */
  57.     }                                                             /*  main  */
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.